***************************************************
* Calculation of Bresnahan-Reiss Entry Thresholds *
***************************************************

qui{	
	margins if high_uninsured==`4' & cat_ucc==1, expression((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1])) atmeans
	matrix t_monopoly = r(b)*`1'
	matrix se_monopoly = r(V)
	matrix se_monopoly = sqrt(se_monopoly[1,1])*`1'

	margins if high_uninsured==`4' & cat_ucc==2, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1] - _b[/ucc_a2]))/2) atmeans
	matrix t_duopoly = r(b)*`1'
	matrix se_duopoly = r(V)
	matrix se_duopoly = sqrt(se_duopoly[1,1])*`1'

	margins if high_uninsured==`4' & cat_ucc==3, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3) atmeans
	matrix t_nfirms3 = r(b)*`1'
	matrix se_f3 = r(V)
	matrix se_f3 = sqrt(se_f3[1,1])*`1'
	
	margins if high_uninsured==`4', expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1] - _b[/ucc_a2]))/2)/((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1]))) atmeans
	matrix t_2f_1f = t_duopoly[1,1]/t_monopoly[1,1]
	matrix se_t21 = r(V)
	matrix se_t21 = sqrt(se_t21[1,1])
	
	margins if high_uninsured==`4', expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3)/(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65  + _b[/ucc_a1] - _b[/ucc_a2]))/2)) atmeans
	matrix t_3f_2f = t_nfirms3[1,1]/t_duopoly[1,1]
	matrix se_t32 = r(V)
	matrix se_t32 = sqrt(se_t32[1,1])
	
	putexcel `3'2 = t_monopoly[1,1]
	putexcel `3'3 = se_monopoly[1,1]
	putexcel `3'4 = t_duopoly[1,1]
	putexcel `3'5 = se_duopoly[1,1]
	putexcel `3'6 = t_nfirms3[1,1]
	putexcel `3'7 = se_f3[1,1]
	putexcel `3'11 = t_2f_1f[1,1]
	putexcel `3'12 = se_t21[1,1]
	putexcel `3'13 = t_3f_2f[1,1]
	putexcel `3'14 = se_t32[1,1]

	margins if high_uninsured==`4' & cat_hosp2==1, expression((_b[hosp_f:con_intensity]*con_intensity + _b[hosp_f:cms_wage_index]*cms_wage_index + _b[/hosp_g1])/(_b[hosp_v:rural]*rural + _b[hosp_v:income_pc]*income_pc + _b[hosp_v:hispanic]*hispanic + _b[hosp_v:nonhisp_black]*nonhisp_black + _b[hosp_v:gte_highschool]*gte_highschool  + _b[hosp_v:age_65]*age_65  + _b[/hosp_a1])/2) atmeans
	matrix t_monopoly_h = r(b)*`2'
	matrix se_monopoly_h = r(V)
	matrix se_monopoly_h = sqrt(se_monopoly_h[1,1])*`2'
		
	putexcel `3'18 = t_monopoly_h[1,1]
	putexcel `3'19 = se_monopoly_h[1,1]

}
